Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

228
Vistas
Specify the direction in findBy Spring data Neo4J queries with depth > 0

I use SDN 4.2.1 to save and load nodes and their relationships in Neo4J.

Until now, I was using findByXXX methods with a depth param equal to 2. Now I need to increase the depth to 3, but the query is far to slow, and I know why : the executed query is not considering the direction of the relationships.

Here is the executed query from the logs (take more than 20 seconds) :

o.n.o.drivers.bolt.request.BoltRequest   : Request: MATCH (n:`Property`) WHERE n.`id` = { `id_0` } WITH n MATCH p=(n)-[*0..3]-(m) RETURN p, ID(n) with params {id_0=P31}

When I rewrite the query with a direction, it becomes very fast :

MATCH (n:`Property`) WHERE n.`id` = "P31" WITH n MATCH p=(n)-[*0..3]->(m) RETURN p, ID(n)

I can't find a way to specify that, in my case, I only want "outgoing" relationships in the findByXXX function declaration of my GraphRepository interface. Is there a parameter like the "@Depth" annotation to give the direction ?

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

There is currently no way of declaring more fine grained queries through annotations. Actually, having some hints in the code about (not) following some paths can be good for a particular use case, but is irrelevant for others.

Looking at what is done for example on JPA : you can use annotations to eagerly load dependent objects. But once an application grows you have to manage FetchProfiles or NamedEntityGraphs to handle the way you fetch according to the use case.

That is why, with SDN 4.x, the preferred way of doing this is to use custom cypher queries. It will ensure you to pick up only the data you need in a performant way.

There is an issue to track this here. Note that it is one of improvements planned for the next major release of OGM / SDN. If you have specific use cases you need to address or ideas around this, feel free to open a discussion on the the slack channel neo4j-users.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda